package com.linwen.javase.new8.optional;

import org.apache.commons.lang3.StringUtils;

import java.util.Optional;

/**
 * @ClassName OptionalUserResporstory
 * @Description TODO
 * @Author zero
 * @DATE 2024/1/19 8:08 AM
 * @Version 1.0
 */
public class OptionalUserRepository {

    public OptionalUser getUser(String name) {
        if(StringUtils.isBlank(name)){
            return null;
        }else{
            return new OptionalUser(name, "20");
        }
    }

    public Optional<OptionalUser> getUser2(String name) {
        if(StringUtils.isBlank(name)){
            return Optional.empty();
        }else{
            return Optional.of(new OptionalUser(name, "20"));
        }
    }
}
